﻿using ProjectScheduling.daos;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ProjectScheduling
{
    public partial class WorkHourStaffDataListForm : Form
    {
        public readonly static WorkHourStaffDataListForm b = new();
        public WorkHourStaffDataListForm()
        {
            InitializeComponent();
            dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
            dataGridView1.AutoGenerateColumns = false;
        }
        public void Init(DateTime start, DateTime end, int staffId)
        {
            var table = new DataTable();
            new List<string> { "StaffName", "ProjectName", "FromDate", "ToDate", "Days" }.ForEach(it => table.Columns.Add(it));
            foreach (var item in PreparedStaffDao.Base.FindStaffList(start, end, staffId))
            {
                var row = table.NewRow();
                row["StaffName"] = item.Content?.StaffName;
                row["ProjectName"] = item.Content?.ProjectName;
                row["FromDate"] = item.Content?.FromDate;
                row["ToDate"] = item.Content?.ToDate;
                row["Days"] = item.Days;
                table.Rows.Add(row);
            }
            dataGridView1.DataSource = table;
            ShowDialog();
        }
        public void Init(DataTable table)
        {
            dataGridView1.DataSource = table;
            ShowDialog();
        }
    }
}
